/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.http.client.jersey.server.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import profile.hujia.http.client.jersey.server.domain.WorkItem;

import java.util.ArrayList;
import java.util.List;

/**
 * class info
 *
 * @author hujia
 * @date 2018/10/26 21:28
 */
@RestController
@RequestMapping("/queue")
@Slf4j
public class QueueController {

    @GetMapping("/view")
    public List<WorkItem> view(@RequestParam String orgBusiness, @RequestParam String workqueue,
                               @RequestParam String busiType, @RequestParam String item,
                               @RequestParam Integer number, @RequestParam Integer currentPage) throws Exception {
        List<WorkItem> workItemList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            WorkItem workItem = new WorkItem();
            workItem.setId("id_00" + i);
            workItem.setBusiType(busiType+i);
            workItem.setBusiType(orgBusiness + i);
            workItem.setName(item + i);
            workItem.setPriority(i);
            workItem.setOrganizationalunit("orgnizationalunit0" + i);
            workItem.setState(3);
            workItem.setTransitRefData5("data00-" + i);
            workItem.setWorkqueue(workqueue + i);
            workItemList.add(workItem);
        }
        return workItemList;
    }

    @PostMapping("/confirm")
    public void addListWorkItem(@RequestBody WorkItem item) {
        log.info(item.getId());
        log.info(item.getOrgBusiness());
        log.info(item.getBusiType());
        log.info(item.getOrganizationalunit());
        log.info(item.getTransitRefData5());
    }

    @PostMapping("/commit")
    public void commit(@RequestBody WorkItem item) {
        log.info(item.getId());
    }

    @PostMapping("/put-list")
    public void putList(@RequestParam List<WorkItem> items){
        log.info(items.toString());
    }
}
